package com.bjxst;

import java.io.FileReader;
import java.io.FileWriter;

/**使用字符流实现文本文件的拷贝处理*/
public class FileCopyToolsTwo {
    public static void main(String[] args) {
        FileReader fr = null;
        FileWriter fw = null;
        try{
            fr = new FileReader("d:/b.txt");
            fw = new FileWriter("d:/c.txt");
            //创建char数组，在字节流则创建int类型的字符流
            char[] buffer = new char[1024];
            int temp =0;
            while ((temp = fr.read(buffer)) != -1){
                fw.write(buffer,0,temp);
            }
            fw.flush();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                //这里没有先后关闭顺序
                if (fr != null){
                    fr.close();
                }
                if(fw != null){
                    fw.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
